package com.ruoyi.bigScreen;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.zzw.BO.AddTPeopleEventBO;
import com.ruoyi.common.core.domain.zzw.BO.DeptBO;
import com.ruoyi.common.core.domain.zzw.TEventManage;
import com.ruoyi.common.core.domain.zzw.TEventTrack;
import com.ruoyi.common.core.domain.zzw.VO.TPeopleManageVO;
import com.ruoyi.common.core.domain.zzw.VO.getRescueListVO;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TPeopleEvent;
import com.ruoyi.system.service.ITEventManageService;
import com.ruoyi.system.service.ITEventTrackService;
import com.ruoyi.system.service.ITPeopleEventService;
import com.ruoyi.system.service.TRescueStrengthService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/screen/rescue")
@Api(tags = "指挥中心-部门人员管理")
public class ScreenTRescueStrengthController {
    @Autowired
    private TRescueStrengthService strengthService;
    @Autowired
    private ITEventManageService tEventManageService;
    @Autowired
    private ITPeopleEventService tPeopleEventService;
    @Autowired
    private ITEventTrackService tEventTrackService;
    @ApiOperation("救援力量-统计应急救援各类别的数量")
    @GetMapping("/rescueNum")
    public AjaxResult getRescueList(){
        getRescueListVO vo=strengthService.getRescueList();
        return AjaxResult.success(vo);
    }
    @GetMapping("/peopletByDept/{cdepartmentId}")
    @ApiOperation("调度中心-根据子部门id分组查询指挥长和值班长")
    public AjaxResult getListByDept( @PathVariable("cdepartmentId") String cdepartmentId){
        return strengthService.getListByDept(cdepartmentId);
    }
    @GetMapping("/peopleLeader")
    @ApiOperation("值班值守-查询各个部门的带班领导top1(默认查全国)")
    public AjaxResult peopleLeader(){
        return strengthService.getLeaderTop();
    }
    @GetMapping("/DeptType")
    @ApiOperation("调度中心-查出所有的部门及其子部门下拉框")
    public AjaxResult DeptType(){
        return strengthService.DeptType();
    }

    @ApiOperation("突发事件列表")
    @GetMapping("/event")
    public AjaxResult pageEvent(String districtId) {
        Page<TEventManage> list = tEventManageService.Event(districtId);
        return AjaxResult.success(list);
    }
    @GetMapping("/trackEvent/{cEventId}")
    @ApiOperation("查询突发事件事件处理情况列表")
    public AjaxResult trackEvent(@PathVariable("cEventId") Long cEventId){
        List<TEventTrack> list = tEventTrackService.listByEventId(cEventId);
        return AjaxResult.success(list);
    }

    @ApiOperation("调度中心保存接口")
    @PostMapping("/addTPeopleEvent")
    public AjaxResult add(@RequestBody AddTPeopleEventBO addTPeopleEventBO)
    {
        return AjaxResult.success(tPeopleEventService.insertTPeopleEvent(addTPeopleEventBO));
    }

    @ApiOperation("根据突发事件id查询绑定的部门和人员信息")
    @GetMapping("/deptAndPeoByEvenId/{cEventId}")
    public AjaxResult deptAndPeoByEvenId(@PathVariable("cEventId") Long cEventId){
        return AjaxResult.success(tPeopleEventService.deptAndPeoByEvenId(cEventId));
    }
    @ApiOperation("根据事件id回显调度中心")
    @GetMapping("/echoByEvenId/{cEventId}")
    public AjaxResult echoByEvenId(@PathVariable("cEventId") Long cEventId){
        return tPeopleEventService.echoByEvenId(cEventId);
    }

    @ApiOperation("统计重大事件和一般事件的数量")
    @GetMapping(value = "/categoryCount")
    public AjaxResult categoryCount(){
        return tEventManageService.categoryCount();
    }
}
